{* Smarty *}
{*
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-07-09 23:15:39 +0200 (Wed, 09 Jul 2008) $
 * $Rev: 1281 $
 * $Author: gavinspearhead $
 * $Id: viewfiles.tpl 1281 2008-07-09 21:15:39Z gavinspearhead $
 *}


{* Capture the skipper: *}
{capture assign=skipper}
<table class="pageskip"><tr>

{* Determine the start/stop page: *}
{assign var="startpage" value="`$currentpage-10`"}
{if $startpage < 1} {assign var="startpage" value="1"} {/if}
{assign var="stoppage" value="`$startpage+20`"}
{if $stoppage > $lastpage} {assign var="stoppage" value=$lastpage} {/if}
{assign var="startpage" value="`$stoppage-20`"}
{if $startpage < 1} {assign var="startpage" value="1"} {/if}

{section name=x loop=$pages}
{* Always do first *}
{if $pages[x].number == 1}
	<td class="ps_{$pages[x].distance}" onmouseover="this.style.color='white'; this.style.cursor='pointer'" onmouseout="this.style.color='black';" onclick="submit_viewfiles_page({$pages[x].url})">
	{$pages[x].number}
	</td>
	{if $startpage > 1}
		<td class="spacer">&nbsp;</td>
	{/if}
{* Always do last *}
{elseif $pages[x].number == $lastpage}
	{if $stoppage < $lastpage}
		<td class="spacer">&nbsp;</td>
	{/if}
	<td class="ps_{$pages[x].distance}" onmouseover="this.style.color='white'; this.style.cursor='pointer'" onmouseout="this.style.color='black';" onclick="submit_viewfiles_page({$pages[x].url})">
	{$pages[x].number}
	</td>
{* Only do the surrounding ones*}
{elseif $pages[x].number >= $startpage AND $pages[x].number <= $stoppage}
	<td class="ps_{$pages[x].distance}" onmouseover="this.style.color='white'; this.style.cursor='pointer'" onmouseout="this.style.color='black';" onclick="submit_viewfiles_page({$pages[x].url})">
	{$pages[x].number}
	</td>
{/if}
{/section}
</tr></table>
{/capture}
{* And display it here and at the bottom: *}
{$skipper}
<div>
<input type="hidden" name="challenge" id="challenge" value="{$challenge}"/>
<input type="hidden" name="offset" id="offset" value="{$offset}"/>
<input type="hidden" name="dir" value="{$directory|escape:htmlall}" id="dir"/>
<input type="hidden" name="dir2" value="{$directory|escape:htmlall|escape}" id="dir2"/>
<input type="hidden" name="sort_dir" value="{$sort_dir}" id="searchdir"/>
<input type="hidden" name="sort" value="{$sort}" id="searchorder"/>
<input type="hidden" name="filename" value="" id="filename"/>
</div>
<table class="files">
<tr class="head">
<th style="width: 30px;">&nbsp;</th>
<th style=""><b><a class="head" href="#" onclick="submit_sort_viewfiles('name')">{$LN_filename}</a></b></th>
<th style=""><b><a class="head" href="#" onclick="submit_sort_viewfiles('type')">{$LN_type}</a></b></th>
<th style=""><b><a class="head" href="#" onclick="submit_sort_viewfiles('size')">{$LN_size}</a></b></th>
<th style=""><b><a class="head" href="#" onclick="submit_sort_viewfiles('mtime')">{$LN_modified}</a></b></th>
<th style=""><b><a class="head" href="#" onclick="submit_sort_viewfiles('perms')">{$LN_perms}</a></b></th>
<th style=""><b><a class="head" href="#" onclick="submit_sort_viewfiles('owner')">{$LN_owner}</a></b></th>
<th style=""><b><a class="head" href="#" onclick="submit_sort_viewfiles('group')">{$LN_group}</a></b></th>
<th style=""><b>{$LN_actions}</b></th>
</tr>

{assign var=counter value=0}

{section name=x loop=$files}

{* Set the correct icon to $icon *}
{assign var=size value=$files[x]->get_size()}
{assign var=perms value=$files[x]->get_perms()}
{assign var=ext value=$files[x]->get_type()}
{assign var=icon value=$files[x]->get_icon()}
{assign var=icon_ln value=$files[x]->get_icon_ln()}
{assign var=name value=$files[x]->get_name()}
{assign var=show_delete value=$files[x]->get_show_delete()}

{if $ext eq 'dir' and $name neq '..'}
	{assign var=size_ext value=$LN_files}
{else}
	{assign var=size_ext value=""}
{/if}

<tr class="{cycle values="even,odd" name="cycle1"}">
<td><img class="noborder" src="{$IMGDIR}/file_icons/{$icon}.png" width="16" height="16" alt="{$icon|capitalize}" {popup text=$icon_ln|capitalize} /></td>
<td>
<input type="hidden" name="file{$counter}" id="file{$counter}" value="{$name|escape:htmlall}"/>
<span class="cursor_hand makelink" onmouseup="javascript:view_files_follow_link(event, '{$files[x]->get_type()}', 'file{$counter}');return false;">{$name|escape:'htmlall'|truncate:$maxstrlen}</span></td>
<td>{$icon_ln}</td>
<td>{$size} {$size_ext|escape}</td>
<td>{$files[x]->get_mtime()}</td>
<td>{$perms}</td>
<td>{$files[x]->get_owner()}</td>
<td>{$files[x]->get_group()}</td>
<td>
{if $name neq '..'}
	<img src="{$IMGDIR}/icon_edit.png" alt="{$LN_viewfiles_rename}" {popup text=$LN_viewfiles_rename|capitalize left=true} class="noborder" onclick="javascript:rename_file_form('file{$counter}');"/>
{if $use_tar neq 0}	<a onclick="submit_viewfiles_action('file{$counter}', 'zip_dir')">
	<img src="{$IMGDIR}/icon_down.png" alt="{$LN_viewfiles_download}" {popup text=$LN_viewfiles_download left=true} class="noborder"/>
	</a>
{/if}
{if $icon eq 'nzb'}
	<a onclick="submit_viewfiles_action('file{$counter}', 'up_nzb')">
	<img src="{$IMGDIR}/icon_play.png" alt="{$LN_viewfiles_uploadnzb}" {popup text=$LN_viewfiles_uploadnzb left=true} class="noborder"/>
	</a>
{else}
	<img src="{$IMGDIR}/pixel.gif" height="16" width="16" class="noborder" alt=""/>
{/if}
{if $show_delete}
	<a onclick="submit_viewfiles_action_confirm('file{$counter}', {if $ext == 'dir'} 'delete_dir' {else} 'delete_file'{/if}, '{$LN_delete} \'@@\'?')">
	<img src="{$IMGDIR}/icon_delete.png" alt="{$LN_viewfiles_delete}" {popup text=$LN_viewfiles_delete|capitalize left=true} class="noborder"/>
	</a>
{/if}
{/if}
</td>
</tr>
{assign var=counter value=$counter+1}
{/section}
</table>

{$skipper}
